package com.shuhan.contronller;

import com.shuhan.entity.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

/**
 * --- 万物归集  不随你我 ---
 * <p>
 * 快捷短语
 * main ==  public static void main(String[] args);
 * sout ==  System.out.println();
 *
 * @author shuhan
 * @date 2025/4/3
 * @desc
 */
@Controller
public class Demo1_SpringMVCtest1 {

    // 接收基本数据int,String,Date...
    @RequestMapping("/revice")
    public String jieshouBase(int id, String username, String password, double score,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") Date birthday, String edu) {

        System.out.println("id = " + id);
        System.out.println("usernaem = " + username);
        System.out.println("password = " + password);
        System.out.println("score = " + score);
        System.out.println("birthday = " + birthday);
        System.out.println("edu = " + edu);

        return "ok.html";

    }

    // 用对象接收前端数据

    @RequestMapping("/user")
    public String reveceUser(User user){
        System.out.println(user.toString());
        return "ok.html";
    }


    /**
     * 路径接收参数需要用@PathVariable 注解放在参数数据类型前进行声明。
     *
     * */

    @GetMapping("/{auterId}/auter/asss/{asssId}")
    public void revecePath(@PathVariable String auterId,@PathVariable String asssId){
        System.out.println("auterId = " + auterId);
        System.out.println("asssId = " + asssId);

    }


}
